package gwt.immunology.client.mvp;

import gwt.immunology.client.ClientFactory;
import gwt.immunology.client.activity.AddPatientActivity;
import gwt.immunology.client.activity.AllPatientsActivity;
import gwt.immunology.client.activity.UserActivity;
import gwt.immunology.client.activity.SearchPatientsActivity;
import gwt.immunology.client.place.AddPatientPlace;
import gwt.immunology.client.place.AllPatientsPlace;
import gwt.immunology.client.place.UserPlace;
import gwt.immunology.client.place.SearchPatientsPlace;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

public class AppActivityMapper implements ActivityMapper {
    private ClientFactory clientFactory;

    public AppActivityMapper(ClientFactory clientFactory) {
        super();
        this.clientFactory = clientFactory;
    }

    @Override
    public Activity getActivity(Place place) {
        if (place instanceof AllPatientsPlace) {
            return new AllPatientsActivity((AllPatientsPlace) place, clientFactory);
        }
        else if (place instanceof AddPatientPlace) {
            return new AddPatientActivity((AddPatientPlace) place, clientFactory);
        }
        else if (place instanceof SearchPatientsPlace) {
            return new SearchPatientsActivity((SearchPatientsPlace) place, clientFactory);
        }
        else if (place instanceof UserPlace) {
            return new UserActivity((UserPlace) place, clientFactory);
        }
            return null;
    }

}
